<?php
session_cache_expire(999999999);
if(!isset($_SESSION)){ 
	session_start(); 
} 
$page = isset ( $_REQUEST["page"] ) ? intval ( $_REQUEST["page"] ) : 1;
$rows_per_page = 20;
$page_start = ( $page - 1 ) * $rows_per_page;
$page_end = $page * $rows_per_page; 
?>
<a class="caption"><?php echo $l_danhsachtinhnang?> </a>
		<div class="divError divinvi" >
			<div class="rf-p divListError">
				<ul>
					<li><a  class="linkAction" href="project.php?projectDetail=project-detail&id=<?=$id?>&tab=1">
						<img src="images/list.png" alt="" />
						<span
							style="display: inline-block; width: 100%"><?php echo $l_error?>
						</span> </a></li>
					<li style="left: 150px"><a  class="linkAction" href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2"><img
							src="images/recyclebin_empty.png" alt="" /><span
							style="display: inline-block; width: 100%"><?php echo $l_newfewture;?>
						</span> </a></li>
					<li style="left: 150px">
						<a  class="linkAction" href="printer/ajax_export_project_listfeatures.php?id=<?=$id?>">
							<img src="images/excel_2003_2_01.png" alt="" />
							<span style="display: inline-block; width: 100%"><?php echo $l_export_excel;?>
							</span> 
						</a>
					</li>	
					<?php if (($_SESSION['poscoder']==1)|| ($_SESSION['posmanager']==1)){ ?>
						<li style="left: 150px">
						<a  class="linkAction" onclick="if(confirm('Do you want notice new version to testers?')){ sendEmailNewVersion('<?=$_SESSION['mangtester']?>','<?=$_SESSION['projectinfo']['namepro_temp']?>'); return true;}else{return false;}">
							<img src="images/newversion.png" alt="" />
							<span style="display: inline-block; width: 100%"><?php echo $l_newversion;?>
							</span> 
						</a>
					</li>
					<?php }?>
				</ul>
			</div>
			<input type="hidden" id="vlisttester" name="vlisttester" value="<?=$mangtester?>"/>
			<input type="hidden" id="nf_lastshowdetail" name="nf_lastshowdetail" />
			<div id='ajaxdelete'>
				<div id="id_nflist">
					<?php 
					$idpro=$_REQUEST['id'];
					$idviewpro=$_SESSION['projectinfo']['idviewpro'];
					$i=0;
					$listnewfeature=array();
					include 'nf_objnewfeature.php';
					include '../operations/connection.php';
					set_time_limit(0);
					$sql="SELECT nf.nfid,nf.pr_idproject,nf.nf_order,nf.nf_title,nf.nf_content,nf.nf_createdate,nf.nf_employee,nf.nf_employee_name, pr.IDView from pr_newfunction nf,pr_project pr WHERE pr.IDProject=nf.pr_idproject and nf.pr_idproject='".$idpro."' ORDER BY nf.nf_createdate desc";
					$query=mysql_query($sql);
					$numcountrow=mysql_num_rows( $query );
					$number_of_page = ceil ( $numcountrow / $rows_per_page );
					?>
					<table width="100%"  class="rf-dt" style="background: #f2f9ff">
					<?php 
					while($row=mysql_fetch_array($query)){
						if ( $i >= $page_start ){
							$obj=new nf_newfeature();
							$obj->init_newfeature(chop($row['nfid']), chop($row['pr_idproject']), chop($row['nf_order']), chop(stripslashes($row['nf_title'])), chop(stripslashes($row['nf_content'])), chop($row['nf_createdate']), chop($row['nf_employee']), chop($row['nf_employee_name']));
							?>
							<tr id="<?php echo 'idviewnewfeature'.(++$i);?>">
								<td class="rf-dt-c" style="width:5% ;vertical-align: middle; text-align: center;min-width: 5%"><?=$i?></td>
								<td class="rf-dt-c" style="width:9%;vertical-align: middle; text-align: center;min-width: 9%"><?=($idviewpro.'-'.$row['nf_order'])?></td>
								<td class="rf-dt-c" style="padding: 7px; vertical-align: middle; width: 50%;cursor: pointer;" onclick="showcomment_newfunction(<?=$i?>,'<?=$obj->nfid?>')">
									<div class="rowMinHeight" align="left" style="width: 97%;" >
										<span class="titleError"><a><?=$obj->nf_title?></a></span>
										<div class="writeBy">
											<div align="right" style="width: 99%; float: left;">
											<span>
												<?php 
													$s1="select nf_contentcomment,nf_employee_name from pr_newfunction_comment where nfid_newfunction='".$obj->nfid."' order by nf_datecomment desc limit 0,1";
													$rs=mysql_query($s1);
													while($r=mysql_fetch_array($rs)){
														$chuoi=chop(stripslashes($r['nf_contentcomment']));
														if(isset($chuoi[27])){
															echo substr($chuoi,0,27)."...(".$r['nf_employee_name'].")";
														}else{
															echo $chuoi." (".$r['nf_employee_name'].")";
														}
													}
												?>
											</span>
											</div>
										</div>
									</div>
								</td>
								<td class="rf-dt-c" style="vertical-align: middle; text-align: center; width: 11%;"><?=$obj->nf_employee_name?></td>
								<td class="rf-dt-c" style="vertical-align: middle; text-align: center; width: 10%;"><?=$obj->nf_createdate?></td>
								<td class="rf-dt-c" style="vertical-align: middle; width: 15%;">
									<div class="divInButton" style="text-align: center;">
										<span title="<?=$l_View?>" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onclick="showcomment_newfunction(<?=$i?>,'<?=$obj->nfid?>')" class="titleError" style="width: 60px" class="odd1" >
											<img src="images/p-view.png" alt="<?php echo $l_View?>" /> 
										</span>
									</div>
								</td>
							</tr>
							<?php 
							$listnewfeature[$i]=$obj;
							if ($i >= $page_end){
								break;
							}
						}else{
							$i++;
						}
					}
					mysql_close($connection);
					$_SESSION['listnewfeature']=$listnewfeature;
					?>
						<tr>
							<td class="rf-dt-ftr-c" style="text-align: center; " colspan="7">
								<span style="padding:1px; display: inline-block;">
									<?php if ( $number_of_page > 1 ) 
									{ 
										if ($page==1)
											$p=2;
										else if ($page==$number_of_page)
											$p=$number_of_page-1;
										else $p=$page;
										if($page!=1){?>
											<a href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2&page=<?=1?>">
				 								<span class="button_next" style="border:none"><?php echo "<<<"?></span></a> 
				 							<a href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2&page=<?=($page-1)?>">
				 								<span onmouseover="" class="button_next" style="border:none"><?php echo "<<"?></span></a>
										<?php  }
										else{
											echo "<span class='button_next' style='cursor:default'><<<</span>"; 
											echo "<span class='button_next' style='cursor:default'><<</span>";
										}
										for ( $i = $p-1; $i <= $p+1; $i++ ) {	
												if ($i<=$number_of_page && $i>0)
													if ($i==$page){
														echo "<span class='button_next' style='color: blue;'><b>".$i."</b></span>"; 
													}else{
													?>
														<a href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2&page=<?=$i?>">
			     	 									<span class="button_next" style="border:none;color: #508e21;" ><b><?php echo $i;?></b></span></a>
														<?php 
													}
												}
											if($page!=$number_of_page){ ?>
												<a href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2&page=<?=($page+1)?>">
				 									<span class="button_next" style="border:none"><?php echo ">>"?> </span></a>
				 								<a href="project.php?projectDetail=project_feature&id=<?=$id?>&tab=2&page=<?=$number_of_page?>">
				 									<span class="button_next" style="border:none"><?php echo ">>>"?> </span></a>
											<?php }
											else{
												echo "<span class='button_next' style='cursor:default'>>></span> ";
												echo "<span class='button_next' style='cursor:default'>>>></span> ";
											}
										}
										?>
								</span>
	               			 </td>
						</tr>
					</table>
				</div>
			</div>
		</div>
